package ren.kane.phoenix.thread;

/**
 * @author renrk(1275) on 2019-08-15 11:13 AM
 **/
public class SleepTest {
    public static void main(String[] args) {
        Thread t = new ThreadD("t");
        t.start();
    }
}

class ThreadD extends Thread {
    public ThreadD(String name) {
        super(name);
    }

    public synchronized void run() {
        try {
            for (int i = 0; i < 10; i++) {
                System.out.printf("%s: %d\n", this.getName(), i);
                // i能被4整除时，休眠1000毫秒
                if (i % 4 == 0)
                    Thread.sleep(1000);
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}